package cn.fzu.menu;

import cn.fzu.frame.StartFrame;
import cn.fzu.util.Tools;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * ClassName : cn.fzu.menu.MineMenuBar
 * Desc : 菜单栏
 *
 * @author : LINPQ
 * @date : 2021/3/27 14:39
 */
public class MineMenuBar extends JMenuBar {

    StartFrame startFrame;
    public MineMenuBar(StartFrame startFrame) {
        this.startFrame = startFrame;
        JMenu game = new JMenu("游戏");
        JMenu help = new JMenu("帮助");

        JMenuItem start = new JMenuItem("开局");
        JMenuItem junior = new JMenuItem("初级");
        JMenuItem middle = new JMenuItem("中级");
        JMenuItem senior = new JMenuItem("高级");
        JMenuItem exit = new JMenuItem("退出");

        JMenuItem copyright = new JMenuItem("版本");

        middle.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Tools.totalMine = 50;
                Tools.rows = 30;
                Tools.cols = 50;

                startFrame.setTime(0);
//                startFrame.getMineState().setTime(0);
                startFrame.restart();
            }
        });


        game.add(start);
        game.add(junior);
        game.add(middle);
        game.add(senior);
        game.add(exit);

        help.add(copyright);

        add(game);
        add(help);


    }
}
